package com.football.springboot.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.football.springboot.entity.GameData;
import com.football.springboot.entity.TeamData;
import com.football.springboot.entity.TeamDataSingle;
import com.football.springboot.mapper.TeamDataSingleMapper;
import com.football.springboot.service.IGameService;
import com.football.springboot.service.ITeamDataSingleService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service
public class TeamDataSingleServiceImpl  extends ServiceImpl<TeamDataSingleMapper, TeamDataSingle> implements ITeamDataSingleService {

    @Resource
    IGameService gameService;

    @Resource
    private TeamDataSingleMapper teamDataSingleMapper;

    @Override
    public TeamDataSingle homegamedatasingle(GameData gameData,Integer gameId) {
        TeamDataSingle homeDataSingle = new TeamDataSingle();
        //主场球队的比赛id
        homeDataSingle.setGameId(gameId);
        //主场球队的球队id
        homeDataSingle.setTeamId(gameService.getById(gameId).getHomeTeam());
        //添加到主场球队的单场数据表中
        homeDataSingle.setSingleGoal(gameData.getHomeGoal());
        homeDataSingle.setSingleFumble(gameData.getAwayGoal());
        homeDataSingle.setSingleControl(gameData.getHomeControl());
        homeDataSingle.setSingleShoot(gameData.getHomeShoot());
        homeDataSingle.setSingleOntarget(gameData.getHomeOntarget());
        homeDataSingle.setSinglePass(gameData.getHomePass());
        homeDataSingle.setSingleOkpass(gameData.getHomeOkpass());
        homeDataSingle.setSingleSurpass(gameData.getHomeSurpass());
        homeDataSingle.setSingleOffside(gameData.getHomeOffside());
        homeDataSingle.setSingleFoul(gameData.getHomeFoul());
        homeDataSingle.setSingleYcard(gameData.getHomeYcard());
        homeDataSingle.setSingleRcard(gameData.getHomeRcard());
        return  homeDataSingle;
    }

    @Override
    public TeamDataSingle awaygamedatasingle(GameData gameData,Integer gameId) {
        TeamDataSingle awayDataSingle = new TeamDataSingle();
        //客场球队的比赛id
        awayDataSingle.setGameId(gameId);
        //客场球队的球队id
        awayDataSingle.setTeamId(gameService.getById(gameId).getAwayTeam());
        //添加到客场球队的单场数据表中
        awayDataSingle.setSingleGoal(gameData.getAwayGoal());
        awayDataSingle.setSingleFumble(gameData.getHomeGoal());
        awayDataSingle.setSingleControl(gameData.getAwayControl());
        awayDataSingle.setSingleShoot(gameData.getAwayShoot());
        awayDataSingle.setSingleOntarget(gameData.getAwayOntarget());
        awayDataSingle.setSinglePass(gameData.getAwayPass());
        awayDataSingle.setSingleOkpass(gameData.getAwayOkpass());
        awayDataSingle.setSingleSurpass(gameData.getAwaySurpass());
        awayDataSingle.setSingleOffside(gameData.getAwayOffside());
        awayDataSingle.setSingleFoul(gameData.getAwayFoul());
        awayDataSingle.setSingleYcard(gameData.getAwayYcard());
        awayDataSingle.setSingleRcard(gameData.getAwayRcard());
        return awayDataSingle;
    }

    @Override
    public TeamDataSingle getteamdatasingle(Integer teamId, Integer gameId) {
        return teamDataSingleMapper.getteamdatasingle(teamId,gameId);
    }


}
